package com.chao.controller;

import com.chao.config.MyRestTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

/**
 * @author Administrator
 * @date 2021-06-16 15:58
 */
@RestController
public class ConsumerController {

    @Autowired
    private MyRestTemplate myRestTemplate;

    @GetMapping("/consumer/getResult/{id}")
    public String getResult(@PathVariable("id") long id){
        RestTemplate restTemplate = myRestTemplate.restTemplate();

        return restTemplate.getForObject("http://cloud-nacos-server/provider/get/"+id,String.class);
    }
}
